Ext.define('Admin.view.needWater.waterSupplyCal.WaterSupplyCal', {
    extend: 'Ext.panel.Panel',
    xtype: 'waterSupplyCal',
    requires: ['Admin.view.needWater.waterSupplyCal.WaterSupplyCalController'],
    controller: 'waterSupplyCalController',
    // margin: 15,
    layout: {
        type: 'vbox',
        align: 'stretch'
    },
    items: [{
        height: 30,
        xtype: 'panel',
        margin: '0 0 5 0',
        cls: 'mytab2-panel',
        items: [{
            html: '<div class="wscal-toptext-row" style="margin:0;">' +
            '<div class="wscal-toptext1"><span>计算方法</span></div>' +
            '<div class="wscal-toptext2"><span>公式</span></div>' +
            '<div class="wscal-toptext3"><span>参考信息</span></div>' +
            '</div>'
        }]
    }, {
        flex: 6,
        xtype: 'panel',
        margin: '0 0 5 0',
        cls: 'mytab2-panel',
        layout: {
            type: 'hbox',
            align: 'stretch'
        },
        items: [{
            flex: 2,
            layout: 'fit',
            padding: 10,
            html: '<div class="ws-cal-desc">' +
            '<div>' +
            '<h5 style="padding-bottom: 10px;font-size: 15px;font-weight: bold;"><strong>正算法</strong></h5>' +
            '<p>适用于南方水资源较丰沛的地区，及沿海独流入海河流</p>' +
            '</div>' +
            '</div>'
        }, {
            flex: 3,
            padding: 10,
            layout: {
                type: 'vbox',
                align: 'stretch'
            },
            items: [{
                xtype: 'panel',
                height: '16%',
            }, {
                xtype: 'radiogroup',
                height: '45%',
                vertical: true,
                reference: 'gpType1',
                columns: 1,
                items: [{
                    boxLabel: '地表水可利用量 = 用水消耗系数 × 最大供水能力 ',
                    inputValue: '1',
                    checked: true
                },
                {
                    boxLabel: '地表水可利用量 = 用水消耗系数 × 最大用水需求 ',
                    inputValue: '2'
                }]
            }, {
                xtype: 'numberfield',
                height: '10%',
                maxWidth: 250,
                labelWidth: 90,
                padding: '5 0 5 55',
                fieldLabel: '用水消耗系数:',
                reference: 'uCe',
                value: '0.8'
            }, {
                xtype: 'numberfield',
                height: '10%',
                maxWidth: 250,
                labelWidth: 150,
                padding: '5 0 5 55',
                value: '25.81',
                reference: 'maxNW',
                fieldLabel: '最大供水能力/用水需求(亿m³):'
            }]
        }, {
            flex: 4,
            // xtype: 'panel',
            // listeners: {
            //     resize: 'buildWSCalChart1'
            // }
            xtype: 'wsChart1'
        }, {
            flex: 3,
            margin: 10,
            xtype: 'grid',
            autoScroll: true,
            loadMask: true,
            stripeRows: true,
            columnLines: true,
            forceFit: true, //表格自适应
            style: 'border: 1px solid #ccc',
            columns: [{
                text: '年份',
                dataIndex: 'p1',
                align: 'center',
                style: 'background: #EEEEEE'
            }, {
                text: '最大供水能力',
                dataIndex: 'p2',
                align: 'center',
                style: 'background: #EEEEEE'
            }],
            //topbar
            tbar: [{
                xtype: "numberfield",
                maxWidth: 85,
                fieldLabel: "",
                labelWidth: 0,
                reference: "bywq",
                value: 2000,
                minValue: 1900
            }, {
                xtype: "numberfield",
                maxWidth: 105,
                fieldLabel: "--",
                labelSeparator: '',
                labelWidth: 15,
                reference: "pyr",
                value: 2015,
                minValue: 1900
            }, {
                xtype: "button",
                text: "查询",
                handler: 'wsCal1Search'
            }],
            store: {
                field: ['year', 'water'],
                data: [{ "p1": "2005", "p2": "19.8" },
                { "p1": "2006", "p2": "20.0" },
                { "p1": "2007", "p2": "23.9" },
                { "p1": "2008", "p2": "25.2" },
                { "p1": "2009", "p2": "28.0" },
                { "p1": "2010", "p2": "26.9" },
                { "p1": "2011", "p2": "31.1" },
                { "p1": "2012", "p2": "28.1" },
                { "p1": "2013", "p2": "29.6" },
                { "p1": "2014", "p2": "30.0" },
                { "p1": "2015", "p2": "31.0" }]
            },
            listeners: {
                itemclick: function (view, record, item, index, e, eOpts) {
                    // console.log(view, record, item, index, e, eOpts)
                }
            }
        }]
    }, {
        xtype: 'panel',
        margin: '0 0 5 0',
        cls: 'mytab2-panel',
        flex: 6,
        layout: {
            type: 'hbox',
            align: 'stretch'
        },
        items: [{
            flex: 2,
            layout: 'fit',
            padding: 10,
            html: '<div class="ws-cal-desc">' +
            '<div>' +
            '<h5 style="padding-bottom: 10px;font-size: 15px;font-weight: bold;"><strong>倒算法</strong></h5>' +
            '<p>一般用于北方水资源紧缺地区地表水可利用量＝地表水资源量－河道内最小生态环境需水量－洪水弃水</p>' +
            '</div>' +
            '</div>'
        }, {
            flex: 7,
            layout: {
                type: 'hbox',
                align: 'stretch'
            },
            padding: 10,
            items: [{
                flex: 1,
                style: 'padding: 20px 0px 20px 50px;',
                layout: {
                    type: 'vbox',
                    align: 'stretch'
                },
                items: [{
                    xtype: 'numberfield',
                    flex: 1,
                    maxWidth: 250,
                    labelWidth: 120,
                    padding: 5,
                    fieldLabel: '地表水资源量(亿m³)',
                    reference: 'swr',
                    value: '222',
                    // 判断是否为数字
                    validator: function (val) {
                        var regex = /^\d+(\.\d+)?$/g;
                        return regex.test(val) ? true : '请输入数字';
                    }
                }, {
                    xtype: 'numberfield',
                    flex: 1,
                    maxWidth: 250,
                    labelWidth: 180,
                    padding: 5,
                    value: '1',
                    reference: 'minRivWat',
                    fieldLabel: '河道内最小环境需水量(亿m³)'
                }, {
                    xtype: 'numberfield',
                    flex: 1,
                    maxWidth: 250,
                    labelWidth: 100,
                    padding: 5,
                    value: '35',
                    reference: 'fDq',
                    fieldLabel: '洪水弃水(亿m³)'
                }]
            }, {
                flex: 1,
                style: 'padding: 20px 0px 20px 50px;',
                layout: {
                    type: 'vbox',
                    align: 'stretch'
                },
                items: [{
                    xtype: 'numberfield',
                    flex: 1,
                    maxWidth: 250,
                    labelWidth: 120,
                    padding: 5,
                    fieldLabel: '天然来流量(亿m³)',
                    reference: 'inq',
                    value: '12.81',
                    // 判断是否为数字
                    validator: function (val) {
                        var regex = /^\d+(\.\d+)?$/g;
                        return regex.test(val) ? true : '请输入数字';
                    }
                }, {
                    xtype: 'numberfield',
                    flex: 1,
                    maxWidth: 250,
                    labelWidth: 120,
                    padding: 5,
                    value: '10',
                    reference: 'totV',
                    fieldLabel: '水库蓄变量(亿m³)'
                }, {
                    xtype: 'numberfield',
                    flex: 1,
                    maxWidth: 250,
                    labelWidth: 120,
                    padding: 5,
                    value: '0',
                    reference: 'tq',
                    fieldLabel: '外调水量(亿m³)'
                }]
            }]
        }, {
            flex: 3,
            margin: 10,
            xtype: 'grid',
            autoScroll: true,
            loadMask: true,
            stripeRows: true,
            columnLines: true,
            forceFit: true, //表格自适应
            style: 'border: 1px solid #ccc',
            columns: [{
                text: '年份',
                dataIndex: 'p1',
                align: 'center',
                style: 'background: #EEEEEE'
            }, {
                text: '河道生态需水量',
                dataIndex: 'p2',
                align: 'right',
                style: 'background: #EEEEEE'
            }, {
                text: '天然径流量',
                dataIndex: 'p3',
                align: 'right',
                style: 'background: #EEEEEE'
            }],
            tbar: [{
                xtype: "numberfield",
                maxWidth: 85,
                fieldLabel: "",
                labelWidth: 0,
                reference: "bywq2",
                value: 2000,
                minValue: 1900
            }, {
                xtype: "numberfield",
                maxWidth: 105,
                fieldLabel: "--",
                labelSeparator: '',
                labelWidth: 15,
                reference: "pyr2",
                value: 2015,
                minValue: 1900
            }, {
                xtype: "button",
                text: "查询",
                handler: 'wsCal1Search'
            }],
            store: {
                field: ['p1', 'p2', 'p3'],
                data: [
                    { "p1": "2005", "p2": "50.7", "p3": "202" },
                    { "p1": "2006", "p2": "50.7", "p3": "222.77" },
                    { "p1": "2007", "p2": "50.7", "p3": "129.09" },
                    { "p1": "2008", "p2": "50.7", "p3": "173.96" },
                    { "p1": "2009", "p2": "50.7", "p3": "146.67" },
                    { "p1": "2010", "p2": "50.7", "p3": "330.33" },
                    { "p1": "2011", "p2": "50.7", "p3": "115.15" },
                    { "p1": "2012", "p2": "50.7", "p3": "303.26" },
                    { "p1": "2013", "p2": "50.7", "p3": "171.74" },
                    { "p1": "2014", "p2": "50.7", "p3": "223.4" },
                    { "p1": "2015", "p2": "50.7", "p3": "265.9" }
                ]
            }
        }]
    }, {
        flex: 6,
        xtype: 'panel',
        margin: '0 0 5 0',
        cls: 'mytab2-panel',
        layout: {
            type: 'hbox',
            align: 'stretch'
        },
        items: [{
            flex: 2,
            layout: 'fit',
            padding: 10,
            html: '<div class="ws-cal-desc">' +
            '<div>' +
            '<h5 style="padding-bottom: 10px;font-size: 15px;font-weight: bold;"><strong>经验公式法</strong></h5>' +
            '<p><strong>天然径流和水库蓄变量与可供水量的关系拟合公式</strong></p>' +
            '</div>' +
            '</div>'
        }, {
            flex: 3,
            padding: '70 10',
            layout: {
                type: 'vbox',
                align: 'stretch'
            },
            items: [{
                flex: 1,
                html: '<p style="padding-left: 55px;">地表水可利用量 = a + b × 天然径流量</p>'
            }, {
                flex: 1,
                xtype: 'numberfield',
                maxWidth: 250,
                labelWidth: 120,
                padding: '5 0 5 55',
                fieldLabel: '天然径流量(亿m³)',
                reference: 'row3p1',
                value: '178',
                // 判断是否为数字
                validator: function (val) {
                    var regex = /^\d+(\.\d+)?$/g;
                    return regex.test(val) ? true : '请输入数字';
                }
            }]
        }, {
            flex: 4,
            xtype: 'wsChart2',
        }, {
            flex: 3,
            margin: 10,
            xtype: 'grid',
            autoScroll: true,
            loadMask: true,
            stripeRows: true,
            columnLines: true,
            forceFit: true, //表格自适应
            style: 'border: 1px solid #ccc',
            columns: [{
                text: '年份',
                dataIndex: 'p1',
                align: 'center',
                style: 'background: #EEEEEE'
            }, {
                text: '天然径流量',
                dataIndex: 'p2',
                align: 'center',
                style: 'background: #EEEEEE'
            }],
            //topbar
            tbar: [{
                xtype: "numberfield",
                maxWidth: 85,
                fieldLabel: "",
                labelWidth: 0,
                reference: "bywq3",
                value: 2000,
                minValue: 1900
            }, {
                xtype: "numberfield",
                maxWidth: 105,
                fieldLabel: "--",
                labelSeparator: '',
                labelWidth: 15,
                reference: "pyr3",
                value: 2015,
                minValue: 1900
            }, {
                xtype: "button",
                text: "查询",
                handler: 'wsCal1Search'
            }],
            store: {
                field: ['year', 'water'],
                data: [{ "p1": "2005", "p2": "202" },
                { "p1": "2006", "p2": "222.77" },
                { "p1": "2007", "p2": "129.09" },
                { "p1": "2008", "p2": "173.96" },
                { "p1": "2009", "p2": "146.67" },
                { "p1": "2010", "p2": "330.33" },
                { "p1": "2011", "p2": "115.15" },
                { "p1": "2012", "p2": "303.26" },
                { "p1": "2013", "p2": "171.74" },
                { "p1": "2014", "p2": "223.4" },
                { "p1": "2015", "p2": "265.9" }]
            },
            listeners: {
                itemclick: function (view, record, item, index, e, eOpts) {
                    // console.log(view, record, item, index, e, eOpts)
                }
            }
        }]
    }, {
        height: 40,
        margin: '0 0 5 0',
        cls: 'mytab2-panel',
        layout: {
            type: 'hbox',
            align: 'stretch'
        },
        items: [{
            width: 100,
            xtype: 'button',
            text: '<span style="font-size:16px;">计算</span>',
            margin: '2 20 2 2',
            handler: 'clacResult'
        }, {
            flex: 1,
            reference: 'resultsP',
            xtype: 'numberfield',
            // maxWidth: 250,
            labelWidth: 110,
            margin: '2 5',
            readOnly: true,
            fieldLabel: '正算法(亿m³)'
        }, {
            flex: 1,
            reference: 'resultsD',
            xtype: 'numberfield',
            // maxWidth: 250,
            labelWidth: 110,
            margin: '2 5',
            readOnly: true,
            fieldLabel: '倒算法(亿m³)'
        }, {
            flex: 1,
            reference: 'resultsEm',
            xtype: 'numberfield',
            // maxWidth: 250,
            labelWidth: 150,
            margin: '2 5',
            readOnly: true,
            fieldLabel: '经验公式算法(亿m³)'
        }, {
            flex: 1,
            reference: 'maxSl',
            xtype: 'numberfield',
            // maxWidth: 250,
            labelWidth: 150,
            margin: '2 5',
            fieldLabel: '推荐可供水量(亿m³)',
            labelStyle: 'color: #FF0033;font-weight: bold;'
        }]
    }],
    listeners: {
        show: 'showPage'
    }
});
